<?php
use yii\helpers\Html;
use yii\widgets\Breadcrumbs;
use frontend\assets\AppAsset;
use yii\widgets\LinkPager;
use frontend\controllers\ListController;
use common\models\member\Member;
use common\models\category\Category;
use common\models\articles\Articles;
use common\models\art\Art;
use common\models\meeting\Meeting;
use common\models\FriendLink\FriendLink;
use common\models\LinkType\LinkType;
use common\models\Fenhuigrade\Fenhuigrade;
use common\models\Ad\AdPosition;
use common\models\Ad\Ad;

    $guanggao = Ad::find()->where(['position_id'=>6])->asArray()->all();//首页banner广告位
    $tongzhi = Articles::find()->where(['category_id'=>18, 'status' => Articles::STATUS_ACTIVE])->asArray()->limit(5)->all();//通知公告
	$zhengce = Articles::find()->where(['category_id'=>25, 'status' => Articles::STATUS_ACTIVE])->asArray()->limit(5)->all();//政策法规
	$hangye = Articles::find()->where(['category_id'=>28, 'status' => Articles::STATUS_ACTIVE])->asArray()->limit(5)->all();//行业研究
	$xinwen = Articles::find()->where(['category_id'=>14, 'status' => Articles::STATUS_ACTIVE])->asArray()->limit(4)->all();//协会新闻
	$jiaoyu = Meeting::find()->where(['category_id'=>19, 'enroll' => Meeting::IS_OPEN])->asArray()->limit(3)->all();//教育培训
	$pinpai = Articles::find()->where(['category_id'=>23, 'status' => Articles::STATUS_ACTIVE])->asArray()->limit(5)->all();//品牌建设
	$dongtai = Articles::find()->where(['category_id'=>14, 'status' => Articles::STATUS_ACTIVE])->asArray()->limit(5)->all();//热门动态
?>

<script type="text/javascript">
$(document).ready(function(){

	$(".main_visual").hover(function(){
		$("#btn_prev,#btn_next").fadeIn()
	},function(){
		$("#btn_prev,#btn_next").fadeOut()
	});
	
	$dragBln = false;
	
	$(".main_image").touchSlider({
		flexible : true,
		speed : 200,
		btn_prev : $("#btn_prev"),
		btn_next : $("#btn_next"),
		paging : $(".flicking_con a"),
		counter : function (e){
			$(".flicking_con a").removeClass("on").eq(e.current-1).addClass("on");
		}
	});
	
	$(".main_image").bind("mousedown", function() {
		$dragBln = false;
	});
	
	$(".main_image").bind("dragstart", function() {
		$dragBln = true;
	});
	
	$(".main_image a").click(function(){
		if($dragBln) {
			return false;
		}
	});
	
	timer = setInterval(function(){
		$("#btn_next").click();
	}, 5000);
	
	$(".main_visual").hover(function(){
		clearInterval(timer);
	},function(){
		timer = setInterval(function(){
			$("#btn_next").click();
		},5000);
	});
	
	$(".main_image").bind("touchstart",function(){
		clearInterval(timer);
	}).bind("touchend", function(){
		timer = setInterval(function(){
			$("#btn_next").click();
		}, 5000);
	});
	
});
</script>
			<section class="banner">
				<div class="main_visual">
					<div class="flicking_con">
						<?php foreach($guanggao as $k=>$vo) { ?>
						<a href="<?= $vo['ad_link']; ?>"><?= $k+1;?></a>
						<?php } ?>
					</div>
					<div class="main_image">
						<ul>
							<?php foreach($guanggao as $vo) { ?>
							<li><a href="<?= $vo['ad_link']; ?>"><img src="<?=Yii::$app->params['setshow']?><?= json_decode($vo['ad_code'], true)['newname'];?>"></a></li>
							<?php } ?>
						</ul>
						<a href="javascript:;" id="btn_prev"></a>
						<a href="javascript:;" id="btn_next"></a>
					</div>
				</div>
			</section>	
				
			<section class="xhnews">
				<div class="sycomtit">
					<div class="letit">协会新闻</div>
					<div class="rgmor"><a href="<?= yii\helpers\Url::to(['list/news', 'id' => 14])?>">更多></a></div>
				</div>
				<div class="xhnews_list">
					<ul>
					    <?php foreach ($xinwen as $vo){?>
						<li>
							<a href="<?= yii\helpers\Url::to(['list/newscontent', 'id' => $vo['id']]);?>">
							<div class="lepic"><img src="<?=Yii::$app->params['setshow']?><?= json_decode($vo['img'], true)['newname'];?>" /></div>
							<div class="rgspan">
							<p class="tit"><?= mb_substr(strip_tags($vo['title']),0,18,'utf-8'); ?><?php if(strlen($vo['title']) > 54) { echo '...'; } ?></p>
							<p class="trt"><?= mb_substr(strip_tags($vo['intro']),0,36,'utf-8'); ?><?php if(strlen($vo['intro']) > 108) { echo '...'; } ?></p>
							</div>
							</a>
						</li>
						<?php } ?>
					</ul>
				</div>
			</section>	
			<section class="dttab">
<script>
$(document).ready(function(){
        $(".tabnew li").click(function(){
        $(".tabnew li").eq($(this).index()).addClass("cur").siblings().removeClass('cur');
$(".tabcont").hide().eq($(this).index()).show();
       //另一种方法: $("div").eq($(".tab li").index(this)).addClass("on").siblings().removeClass('on'); 

        });
    });
</script>
				
				<div class="tabnew">
			        <ul>
			           <li class="cur">热点动态</li>
			           <li>通知公告</li>
			           <li>政策法规</li>
			           <li>行业研究</li>
			           <li>品牌建设</li>
			       </ul>
			    </div> 
			 
			    <div class="tabcont on">
			    	<ul>
					 <?php foreach($dongtai as $vo){?>
			    		<li><a href="<?= yii\helpers\Url::to(['list/newscontent', 'id' => $vo['id']]);?>"><?= mb_substr(strip_tags($vo['title']),0,22,'utf-8'); ?><?php if(strlen($vo['title']) > 66) { echo '...'; } ?></a></li>
					 <?php } ?>
			    	</ul>
			    	<div class="jzmorbtn">
			    	<p class="jzmor"></p>
			    	<p class="jzmorspan"><a href="<?= yii\helpers\Url::to(['list/news', 'id' => 14])?>">加载更多 >></a></p>
			    	</div>
			    	
			    </div>
			    <div class="tabcont">
			    	<ul>
					<?php foreach($tongzhi as $vo){?>
			    		<li><a href="<?= yii\helpers\Url::to(['list/newscontent', 'id' => $vo['id']]);?>"><?= mb_substr(strip_tags($vo['title']),0,22,'utf-8'); ?><?php if(strlen($vo['title']) > 66) { echo '...'; } ?></a></li>
			    	<?php } ?>
			    		
			    	</ul>
			    	<div class="jzmorbtn">
			    	<p class="jzmor"></p>
			    	<p class="jzmorspan"><a href="<?= yii\helpers\Url::to(['list/news', 'id' => 18])?>">加载更多 >></a></p>
			    	</div>
			    </div>
			    <div class="tabcont">
			    	<ul>
					<?php foreach($zhengce as $vo){ ?>
			    		<li><a href="<?= yii\helpers\Url::to(['list/newscontent', 'id' => $vo['id']]);?>"><?= mb_substr(strip_tags($vo['title']),0,22,'utf-8'); ?><?php if(strlen($vo['title']) > 66) { echo '...'; } ?></a></li>
			        <?php } ?>
			    		
			    	</ul>
			    	<div class="jzmorbtn">
			    	<p class="jzmor"></p>
			    	<p class="jzmorspan"><a href="<?= yii\helpers\Url::to(['list/news', 'id' => 25])?>">加载更多 >></a></p>
			    	</div>
			    </div>
			    <div class="tabcont">
			    	<ul>
					<?php foreach($hangye as $vo){ ?>
			    		<li><a href="<?= yii\helpers\Url::to(['list/newscontent', 'id' => $vo['id']]);?>"><?= mb_substr(strip_tags($vo['title']),0,22,'utf-8'); ?><?php if(strlen($vo['title']) > 66) { echo '...'; } ?></a></li>
                    <?php } ?>
			    		
			    	</ul>
			    	<div class="jzmorbtn">
			    	<p class="jzmor"></p>
			    	<p class="jzmorspan"><a href="<?= yii\helpers\Url::to(['list/news', 'id' =>28])?>">加载更多 >></a></p>
			    	</div>
			    </div>
			    <div class="tabcont">
			    	<ul>
					<?php foreach($pinpai as $vo){ ?>
			    		<li><a href="<?= yii\helpers\Url::to(['list/newscontent', 'id' => $vo['id']]);?>"><?= mb_substr(strip_tags($vo['title']),0,22,'utf-8'); ?><?php if(strlen($vo['title']) > 66) { echo '...'; } ?></a></li>
                    <?php } ?>
			    		
			    	</ul>
			    	<div class="jzmorbtn">
			    	<p class="jzmor"></p>
			    	<p class="jzmorspan"><a href="<?= yii\helpers\Url::to(['list/news', 'id' => 23])?>">加载更多 >></a></p>
			    	</div>
			    </div>
				
			</section>
			
			<section class="xhnews">
				<div class="sycomtit">
					<div class="letit">教育培训</div>
					<div class="rgmor"><a href="<?= yii\helpers\Url::to(['list/train', 'id' => 19])?>">更多></a></div>
				</div>
				<div class="education_list">
					<ul>
                        <?php foreach($jiaoyu as $vo){ ?>
                        <?php if(strtotime($vo['deadline']) > time()) { ?>
						<li>
							<div class="lepic"><a href="<?= yii\helpers\Url::to(['list/traincontent', 'id' => $vo['id']]); ?>"><img src="<?=Yii::$app->params['setshow']?><?= json_decode($vo['label_img'], true)['newname'];?>" /></a></div>
							<div class="rgspan">
								<p class="tit"><a href="<?= yii\helpers\Url::to(['list/traincontent', 'id' => $vo['id']]); ?>"><?php echo(mb_substr(strip_tags($vo['title']),0,22,'utf-8'));?><?php if(strlen($vo['title']) > 66) { echo '...'; } ?></a></p>
								<p class="trt"><a href="<?= yii\helpers\Url::to(['meetingenroll/create', 'id' => $vo['id']]);?>">立即报名</a></p>
							</div>
						</li>
						<?php } else { ?>
						<li>
							<div class="lepic"><a><img src="<?=Yii::$app->params['setshow']?><?= json_decode($vo['label_img'], true)['newname'];?>" /></a></div>
							<div class="rgspan">
								<p class="tit"><a><?php echo(mb_substr(strip_tags($vo['title']),0,22,'utf-8'));?></a></p>
								<p class="trt"><a style="background-color: #777777; color: #fff;">已结束</a></p>
							</div>
						</li>
						<?php } ?>
						<?php } ?>
					</ul>
					
				</div>
				
			</section>
			
			<footer>
				<div class="footnav">
					<ul>
						<li><a href="<?= yii\helpers\Url::to(['content/index', 'id' => 8])?>">关于我们</a> &nbsp; |</li>
						<li><a href="<?= yii\helpers\Url::to(['content/index', 'id' => 30])?>">联系我们</a> &nbsp; |</li>
						<li><a href="">帮助中心</a> &nbsp; |</li>
						<li><a href="">网站地图</a></li>
					</ul>
				</div>
				<div class="right">© 北京市丰台区餐饮住宿服务行业协会 版权所有</div>
			</footer>
			
			<div class="fhdiv">
	            <div class="telbtn">
	                <a href="tel:0000000"><img src="img/blphone.png" alt="" class="blphone"/></a>
	            </div>
	            <div class="topbtn">
	                <a href="#top" name="top"><img src="img/blup.png" alt="" class="blup"/></a>
	            </div>
	        </div>